package com.heima.wemedia.controller.v1;

import com.heima.model.wemedia.dtos.SensitivePageReqDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.SensitiveService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * Author: Administrator
 * CreateTime: 2024/10/9
 * Project: heima-leadnews
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@RequiredArgsConstructor
public class SensitiveController {

    private final SensitiveService sensitiveService;

    /**
     * 敏感词查询
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody SensitivePageReqDto sensitivePageReqDto) {
        return sensitiveService.list(sensitivePageReqDto);
    }

    /**
     * 删除敏感词
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult del(@PathVariable Integer id) {
        return sensitiveService.del(id);
    }

    /**
     * 保存敏感词
     * @param wmSensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmSensitive wmSensitive) {
        return sensitiveService.add(wmSensitive);
    }

    /**
     * 更新敏感词
     * @param wmSensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmSensitive wmSensitive) {
        return sensitiveService.update(wmSensitive);
    }
}
